package org.llc.flink.study.example


object List11 {
  def main(args: Array[String]): Unit = {
    // 获得迭代器
    val iterator = List(1, 2, 3, 4).iterator

    println("-------------------遍历方式一 while------------------------")

    /**
      * while (iterator.hasNext) {
      * println(iterator.next())
      * }
      */
    println("-------------------遍历方式一 for------------------------")
    for (item <- iterator) {
      println(item)
    }

    /** 这里我们看看iterator 的继承关系
      * def iterator: Iterator[A] = new AbstractIterator[A] {
      * var these = self
      * def hasNext: Boolean = !these.isEmpty
      * def next(): A = if (hasNext) {val result = these.head; these = these.tail; result} else Iterator.empty.next()
      * // ......
      * }
      */

  }
}
